package com.design.designmode.create.factory.simple;

/**
 * 1.简单工厂
 *
 * @author hxl
 * @since 2023-04-15
 */
public class SimpleFactory {

    public static void main(String[] args) {
        Product product = SimpleFactory.createProduct("B");
        product.info();
    }

    public static Product createProduct(String type) {
        Product product = null;
        switch (type) {
            case "A":
                product = new ProductA();
                break;
            case "B":
                product = new ProductB();
                break;
            default:
                product = null;
        }
        return product;
    }

}
